import dash
import feffery_antd_components as fac
from dash import html
from dash.dependencies import Input, Output, MATCH

from server import app

layout = html.Div(
    [
        fac.AntdSpace(
            [
                fac.AntdSpace(
                    [
                        fac.AntdButton(
                            f'按钮{i}',
                            id={
                                'type': 'tab4-demo-button',
                                'index': str(i)
                            }
                        ),
                        fac.AntdText(
                            id={
                                'type': 'tab4-demo-output',
                                'index': str(i)
                            }
                        )
                    ]
                )
                for i in range(10)
            ],
            direction='vertical'
        )
    ]
)


@app.callback(
    Output({'type': 'tab4-demo-output', 'index': MATCH}, 'children'),
    Input({'type': 'tab4-demo-button', 'index': MATCH}, 'nClicks')
)
def tab4_callback_demo(nClicks):
    if nClicks:
        return nClicks

    return dash.no_update
